import Vue from 'vue';
import VueRouter from 'vue-router';

Vue.use(VueRouter);  //使用路由


const routes = [  
    {
        path:"/demo1",
        name:"demo1",
        component:() => import("@/views/demo1/demo1.vue")
    },
    {
        path:"/demo2",
        name:"demo2",
        component:() => import("@/views/demo2/demo2.vue")
    },
    {
        path:"/demo3",
        name:"demo3",
        component:() => import("@/views/demo3/demo3.vue")
    }
];

const router = new VueRouter({
    routes
})
//全局前置路由守卫
/*
router.beforeEach((to,from,next)=>{
    let token = localStorage.getItem("user_token");
    if(to.path == '/login'|| to.path =='/register'){
        next();
    }else{
        if(token != null){
            next();
        }else{
            next("/login");
        }
    }
})
*/
export default router;